<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Sugar</title>
</head>

<body>
  <script>
    const oldCateList = [
      { id: 0, name: '热点' },
      { id: 999, name: '关注' },
      { id: 1, name: '科技' },
      { id: 2, name: '教育' },
    ];

    // 1. 遍历
    // 2. 映射
    // 3. 返回新数组
    const newCateList = oldCateList.map(item => {
      return {
        // ... 展开运算符
        ...item,
        // 初始化一个空数组到分类中，虽然是空数组但是也能调用数组的属性和方法
        postList: []   // new Array()
      }
    })

    console.log('oldCateList', oldCateList);
    console.log('newCateList', newCateList);

    // [].length     [].push()

  </script>
</body>

</html>